function InitHealthDataList() {
    fillHealthInputData();
}

function lookupHealthData(healthInputData){
    var healthInputDataType = healthInputData.valueType;

    for(var i = 0; i < $N.ctrl.util.healthDataTypeEnum.length; i ++) {
        if($N.ctrl.util.healthDataTypeEnum[i].type === healthInputDataType.valueType) {
            return $N.ctrl.util.healthDataTypeEnum[i];
        }
    }
    return null;
}

function showHealthInputData(){
    var healthInputData = $N.ctrl.HealthInputDataCtrl.healthInputData;
    if(healthInputData.length == 0) {
        return;
    }
    var $list = $('.health-input-data');
    $('li > .placeholder').remove();
    for(var i = 0; i < healthInputData.length; i ++) {
        var $item = $('<li></li>');
        var healthDataTypeObj = lookupHealthData(healthInputData[i]);
        if(healthDataTypeObj !== null) {
      		$item.data('value-type', healthDataTypeObj.type);
      		$item.data('value-data', healthDataTypeObj.valueData);
      		$item.data('value-unit', healthDataTypeObj.unit);
      		
            var text = healthDataTypeObj.type + healthInputData[i].valueData + healthDataTypeObj.unit; 
            $item.html(text);
            $list.append($item);
        }
    }
}

function fillHealthInputData() {
    var personProfile = $N.ctrl.PersonProfileCtrl.getSelectedData();
    var personID = personProfile.personID;
    console.log("personID = " + personProfile.personID);
   
    $N.ctrl.HealthInputDataCtrl.registerClientNotify(showHealthInputData);
    $N.ctrl.HealthInputDataCtrl.getHealthInputData(personID);
}
